package com.spark.lola.logistics.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.spark.lola.logistics.constant.LogisticsConstant;
import com.spark.lola.support.common.entity.ShiroUser;
import com.spark.lola.support.mybatis.entity.BaseModel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.Date;

/**
 * @author: Zhi-peng wang
 * @date: 2020/04/26 15:56
 * 货运单流程记录
 **/
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "OrderProcess", description = "货运单流程记录")
@TableName("logistics_order_process")
public class OrderProcess extends BaseModel {

    @ApiModelProperty(name = "orderId", value = "订单id")
    private Long orderId;

    @ApiModelProperty(name = "orderNo", value = "订单编号")
    private String orderNo;

    @ApiModelProperty(name = "userId", value = "操作人id")
    private Long userId;

    @ApiModelProperty(name = "userType", value = "用户类型")
    private String userType;

    @ApiModelProperty(name = "name", value = "用户名")
    private String name;

    @ApiModelProperty(name = "actionCode", value = "操作编码")
    private Integer actionCode;

    @ApiModelProperty(name = "actionName", value = "操作名")
    private String actionName;

    @ApiModelProperty(name = "info", value = "操作内容")
    private String info;

    @ApiModelProperty(name = "intro", value = "描述")
    private String intro;

    @ApiModelProperty(name = "credentials", value = "凭据")
    private String credentials;

    @ApiModelProperty(name = "flag", value = "对应action相同时是否最新操作", notes = "0-历史，1-最新")
    private Integer flag = LogisticsConstant.ProcessFlag.NEWEST;

    @ApiModelProperty(name = "createTime", value = "创建时间")
    @TableField(fill = FieldFill.INSERT)
    private Date createTime;

    public OrderProcess(Long orderId, String orderNo, ShiroUser shiroUser, Integer actionCode, String actionName, String info, String intro, String credentials) {
        this.orderId = orderId;
        this.orderNo = orderNo;
        this.userId = shiroUser.getId();
        this.userType = shiroUser.getDutyId().toString();
        this.name = shiroUser.getLoginNo();
        this.actionCode = actionCode;
        this.actionName = actionName;
        this.info = info;
        this.intro = intro;
        this.credentials =credentials;
    }
}
